package com.zxy.hotel.controller;


import com.zxy.hotel.entity.RS;
import com.zxy.hotel.entity.Room;
import com.zxy.hotel.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author jiusi
 * @since 2021-12-12
 */
@RestController
@RequestMapping("/room")
@PreAuthorize("hasAnyRole('admin','root','staff')")
public class RoomController {

    @Autowired
    private RoomService roomService;

    @GetMapping
    public RS room(String type) {
        List<Room> list = roomService.getRoomList(type);
        return RS.ok().data(list);
    }

    @GetMapping("/count")
    public RS count() {
        Map<String, Integer> m = roomService.getRoomCount();
        return RS.ok().data(m);
    }

}
